﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PNProject.EF;
using PNProject.Core;

namespace PNProject.Core.Converter
{
    public class LibConverter
    {
        public static Library ToLib(LibModel lib)
        {
            Library obj = new Library();
            try
            {
                obj.ElementID = lib.ElementID;
                obj.Title = lib.Title;
                obj.URL = lib.URL;
                obj.CreateDate = lib.CreateDate;
                obj.Lang = lib.Lang;
                obj.Type = lib.Type;
                obj.IsPublic = lib.IsPublic;
                obj.ViewCount = lib.ViewCount;
                obj.TLink = lib.TLink;
                obj.LibContent = lib.LibContent;
                return obj;
            }
            catch (Exception e)
            {
                return new Library();
            }
        }

        public static Library CopyLib(Library lib)
        {
            Library obj = new Library();
            try
            {
                obj.ElementID = lib.ElementID;
                obj.Title = lib.Title;
                obj.URL = lib.URL;
                obj.CreateDate = lib.CreateDate;
                obj.Lang = lib.Lang;
                obj.Type = lib.Type;
                obj.IsPublic = lib.IsPublic;
                obj.ViewCount = lib.ViewCount;
                obj.TLink = lib.TLink;
                obj.LibContent = lib.LibContent;
                return obj;
            }
            catch (Exception e)
            {
                return new Library();
            }
        }

        public static LibModel LibTo(Library lib)
        {
            LibModel obj = new LibModel();
            obj.ElementID = lib.ElementID;
            obj.Title = lib.Title;
            obj.URL = lib.URL;
            obj.CreateDate = lib.CreateDate;
            obj.Lang = lib.Lang;
            obj.Type = lib.Type;
            obj.IsPublic = lib.IsPublic;
            obj.ViewCount = lib.ViewCount;
            obj.TLink = lib.TLink;
            obj.LibContent = lib.LibContent;
            return obj;
        }
    }
}